package vcproj2cmake.reader;
import java.io.IOException;
import java.util.ArrayList;

import vcproj2cmake.Solution;

import jtools.files.TextFile;



public class SLNReader {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		if (args.length < 1){
			System.out.println("<Usage>::project.sln");
			System.exit(1);
		}
		TextFile tf = new TextFile();
		tf.readFile(args[0], false);
			
		ArrayList<String> projectFiles = new ArrayList<String>();
		ArrayList<String> projectNames = new ArrayList<String>();
		Solution solution;
		while(tf.hasNext()){
			String line = tf.getNextLine();
			if (line.contains(".vcproj")){
				String[] tmp = line.split(",");
				for (int i = 0; i < tmp.length; i++){
					if (tmp[i].contains(".vcproj")){
						projectFiles.add(tmp[i].replace("\"", "").trim());
						projectNames.add(tmp[i-1].split("=")[1].replace("\"", "").trim());
						System.out.println("Found Project: " + projectNames.get(projectNames.size()-1) + " : " + projectFiles.get(projectFiles.size()-1));
						System.out.println("ID: "+ tmp[i-1].split("=")[0].replace("Project(\"{", "").replace("}\") ", ""));
					}
				}
			}
		}
	}

}
